<!DOCTYPE html>
<html>
<head>
    <title>GH-1054</title>
</head>
<body>
<input value="Initial value">
<div contenteditable="true">Initial value</div>
<script>
    window.storedValue = '';

    const input = document.querySelector('input');
    const div   = document.querySelector('div');

    const storeValue = function (event) {
        const target = event.target;

        window.storedValue = target.value || target.innerText;

        target.removeEventListener('input', storeValue);
    };

    input.addEventListener('input', storeValue);
    div.addEventListener('input', storeValue);
</script>
</body>
</html>
